package com.SmartCare.controller.client;

import com.SmartCare.common.Result;
import com.SmartCare.common.note.Monitor;
import com.SmartCare.service.AttendanceService;
import io.swagger.annotations.Api;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping("/attendance")
@Api(tags = "C端签到签退相关接口")
@Slf4j
public class AttendanceController {
    @Autowired
    private AttendanceService  attendanceService;

    /**
     * 签到
     */
    @GetMapping("/checkin")
    public Result checkIn(Long visitorId,Long elderId) {
       return attendanceService.checkIn(visitorId,elderId);
    }

    /**
     * 签退
     */
    @GetMapping("/checkout")
    public Result checkOut(Long id) {
        return attendanceService.checkOut(id);
    }

    /**
     * 个人线下访问记录查询
     */
    @GetMapping("/duration/{visitorId}")
    @Monitor(description = "个人线下访问记录查询", module = "排行榜模块")
    public Result getOneInfo(@PathVariable Long visitorId){
        return attendanceService.getOneInfo(visitorId);
    }

    /**
     * 查看排行榜
     */
    @GetMapping("/top")
    @Monitor(description = "查看排行榜", module = "排行榜模块")
    public Result getTop(Integer flag) {
        return attendanceService.getTop(flag);
    }

    /**
     * 签到信息查询
     */
    @GetMapping("/is_signIn")
    public Result getSignInfo(Long visitorId,Long elderId){
        return attendanceService.getSignInfo(visitorId,elderId);
    }
}
